<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>axios post</title>
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>

<body>
    <div id='app'>
        <input type="file" @change="handleChange($event,'其他参数')">

        <button @click="upload">上传</button>

        <div @click="click1" style="height: 400px;background-color: lightblue;">
            <div @click="click2" style="height: 200px;background-color: lightgreen;"></div>
        </div>
    </div>
    <script>
        const vm = new Vue({
            el: '#app',
            data: {
                file: null
            },
            methods: {
                handleChange(e,other) {
                    // debugger
                    // 上传文件到服务器
                    this.file = e.currentTarget.files[0]
                    console.log(other);
                },
                upload() {
                    // localStorage
                    // sessionStorage
                    // cookie 4k

                    const formdata = new FormData()
                    formdata.append('file', this.file)
                    formdata.append('fileUseForEnum', 'DEFAULT')
                
                    axios.post('http://192.168.0.173:8088/api/nos/upload/image', formdata).then(
                        res => {
                            debugger
                        })

                },
                click1(e) {
                    // debugger
                    // 当前事件的dom对象
                    // currentTarget
                    // 当前事件源的dom对象
                    // target
                },
                click2(e) {
                    // debugger
                }
            },
        })
    </script>
</body>

</html>